package com.cn.ycy.proxy.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class CustomInterceptor implements MethodInterceptor {

  /**
   * 这个地方 和 cglib 不同，不需要为 代理类 实例化代理对象
   */
  Object student;

  public CustomInterceptor() {
  }

  public CustomInterceptor(Object student) {
    this.student = student;
  }

  @Override
  public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
    System.out.println("代理对象 ido first");
//    return proxy.invokeSuper(obj, args);
    return proxy.invoke(student, args);
  }
}
